<?php
function InnoForum_moderateajax_permission()
{
  // Security check
  //we are allow for admin access level , see in config.php variable name ACCESS_EDIT
  if (!SecurityUtil::checkPermission('InnoForum::', '::', ACCESS_MODERATE)) {
      LogUtil::registerPermissionError(pnModUrl('Users','user','loginscreen'));
  }
}

  function InnoForum_moderateajax_main (){
    InnoForum_moderateajax_validateFinnance ();
  }

  function InnoForum_moderateajax_validateFinnance(){
    InnoForum_moderateajax_permission();
    $topic_id =  FormUtil::getPassedValue ('topic_id', null);
    $uid =  FormUtil::getPassedValue ('uid', null);

    //Check exist user & topic
    $pntables = pnDBGetTables();
    $financeTable  = $pntables['innoforum_finance'];
    $financeColumn = $pntables['innoforum_finance_column'];

    $sql = "SELECT $financeTable.$financeColumn[uid] 
            FROM   $financeTable 
            WHERE  $financeTable.$financeColumn[uid] = ".$uid." 
            AND    $financeTable.$financeColumn[topic_id] = ".$topic_id;

    $column = array("username");
    $result = DBUtil::executeSQL($sql);
    $objectArray = DBUtil::marshallObjects ($result, $column);
    if(trim($objectArray['0']['username']) != "" && isset($objectArray['0']['username'])){
        echo "false";
    }else{
        echo "true";
    }
    return true;
  }

?>

